package com.demo.camunda.controller;


import com.demo.camunda.ReponseBO.UserRpBO;
import com.demo.camunda.camundaBO.ActivitiHighLineBO;
import com.demo.camunda.service.queryService;
import org.camunda.bpm.engine.*;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/query")
public class queryController {


    @Resource
    private RepositoryService repositoryService;
    @Resource
    private RuntimeService runtimeService;
    @Resource
    private ManagementService managementService;
    @Resource
    private TaskService taskService;
    @Resource
    private ProcessEngine processEngine;

    @Resource
    private queryService queryService;


    //查询活动实例
    @PostMapping("/queryActivityInstance/{pageIndex}")
    public Map<String, Object> queryActivityInstance(@PathVariable int pageIndex){
        Map<String, Object> map = queryService.queryActivityInstance(pageIndex);
        return map;
    }


    //查询历史实例
    @PostMapping("/queryHistoryInstance/{pageIndex}")
    public Map<String, Object> queryHistoryInstance(@PathVariable int pageIndex){
        Map<String, Object> map = queryService.queryHistoryInstance(pageIndex);
        return map;
    }


    @PostMapping("/queryActivity")
    public ActivitiHighLineBO queryActivity(String id){
        ActivitiHighLineBO map = queryService.queryActivity(id);
        return map;
    }

    @PostMapping("/ss")
    public String ss(String id){
        Map<String, Object> map = new HashMap<>();
        map.put("user1","tym");
        ProcessInstance processInstance = runtimeService.startProcessInstanceById(id, map);
        String ids = processInstance.getId();
        return ids;
    }



}
